import * as obj from "../public.js";
import { ajax } from "../../public/promiseAjax.js";
const o = obj.default;
// o.$('')
const btn = o.$('.btn')



btn.onclick = function () {
  const imgs = o.$('.imgs').value
  const pricec = o.$('.pricec').value
  const freeShipping = o.$('.freeShipping').value
  const buyers = o.$('.buyers').value
  const name = o.$('.name').value
  const tel = o.$('.tel').value
  const merchant = o.$('.merchant').value
  const shippingPlace = o.$('.shippingPlace').value
  const collections = o.$('.collections').value
  if (imgs && pricec && freeShipping && buyers && name && merchant && shippingPlace && tel) {
    const all = ['food','cosmetology','clean','toy','clothing','discipline','livingbody']
    if(all.indexOf(collections) !== -1){
    ajax({
      url: 'http://localhost/pushCart',
      method:'post',
      data:{
        imgs,pricec,freeShipping,buyers:`${buyers}人付款`,name,merchant,shippingPlace,tel,collections
      }
    }).then(res=>{
      console.log(res)
    })
    }else{
      alert(collections)
    }

  } else { console.log(2) }
}



// let str = ` <div class="con_goods">
//     <img src="${imgs}" alt="">
//     <div class="s_name">${pricec}<i>${freeShipping}</i> <span>${buyers}</span></div>
//     <p>${name}</p>
//     <div class="shop">${merchant}<em>${shippingPlace}/em></div>
//   </div>`




// console.log(btn)
// console.log(pricec)
// console.log(freeShipping)
// console.log(buyers)
// console.log(name)
// console.log(merchant)
// console.log(shippingPlace)
